<template>
	<view class="content">
		<view class="qr-con">
			<view style="margin-bottom: 100rpx;">
				<tki-barcode ref="barcode" cid="qrcodeB" :val="patientId" :opations="opations" />
			</view>
			<canvas canvas-id="qrcodeA" style="width: 210px;height: 210px;"></canvas>
			<!-- <image src="../../static/img/qrcode.png" style="width: 438rpx;height: 438rpx;"></image> -->
			<view style="margin-top: 23rpx;">
				就诊时请出示就诊码进行就诊
			</view>
		</view>
	</view>
</template>

<script>
	import UQRCode from 'uqrcodejs';
	import tkiBarcode from "@/components/tki-barcode/tki-barcode.vue"
	export default {
		data() {
			return {
				patientId: '',
				opations: {
					width: 6,
					height: 140
				}
			}
		},
		components: {
			tkiBarcode
		},
		onLoad(option) {
			console.log(option.patientId);
			this.patientId = option.patientId

		},
		mounted() {
			this.makeQrcode(this.patientId)
		},
		methods: {
			makeQrcode(id) {
				// 获取uQRCode实例
				var qr = new UQRCode();
				console.log(qr);
				// 设置二维码内容
				qr.data = id;
				// 设置二维码大小，必须与canvas设置的宽高一致
				qr.size = 210;
				// 调用制作二维码方法
				qr.make();
				// 获取canvas上下文
				var canvasContext = uni.createCanvasContext('qrcodeA', this); // 如果是组件，this必须传入

				// 设置uQRCode实例的canvas上下文
				qr.canvasContext = canvasContext;
				// 调用绘制方法将二维码图案绘制到canvas上
				qr.drawCanvas();
			},
		}
	}
</script>

<style scoped>
	.content {
		width: 100vw;
		height: 100%;
		background-image: url(../../static/img/bg_information_l.png);
		background-repeat: no-repeat;
		background-size: cover;
		color: #999999;
		font-size: 27rpx;
		padding-top: 100rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		box-sizing: border-box;
	}

	.qr-con {
		width: 688rpx;
		padding-top: 46rpx;
		padding-bottom: 200rpx;
		background: #FFFFFF;
		border-radius: 19rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
</style>